<template>
  <!-- 添加或修改项目基础信息管理对话框 -->
  <div>
     <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" append-to-body v-dialogDrag width="90%">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
             label-width="98px">
      <el-form-item label="关联销售订单单行金具编码" prop="goodsCode">
        <el-input v-model="queryParams.goodsCode" placeholder="请输入关联销售订单单行金具编码"
                  clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="关联销售订单单行金具名称" prop="goodsName">
        <el-input v-model="queryParams.goodsName" placeholder="请输入关联销售订单单行金具名称"
                  clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="关联销售订单单行金具型号" prop="goodsModel">
        <el-input v-model="queryParams.goodsModel" placeholder="请输入关联销售订单单行金具型号"
                  clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="columns" ref="dragTable" row-key="id" v-loading="loading">
        <el-table-column align="center" label="序号" type="index" width="50">
          <template slot-scope="scope">
            <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column label="销售订单号" align="center" prop="projectCode" show-overflow-tooltip/>
        <!--<el-table-column label="销售订单名称" align="center" prop="order.projectName" show-overflow-tooltip/>-->
        <el-table-column label="合同产品名称" align="center" prop="name" show-overflow-tooltip/>
        <el-table-column label="合同产品型号" align="center" prop="models"/>
        <el-table-column align="center" label="工程名称" prop="gongchengName" show-overflow-tooltip/>
        <el-table-column align="center" label="关联销售订单单行金具编码" prop="goodsCode"/>
        <el-table-column align="center" label="关联销售订单单行金具名称" prop="goodsName"/>
        <el-table-column align="center" label="关联销售订单单行金具型号" prop="goodsModel"/>
        <el-table-column align="center" label="串里面的数量" prop="count"/>
        <el-table-column align="center" label="合同数量" prop="weight"/>
        <el-table-column align="center" label="总数量" prop="goodsCount"/>
        <el-table-column align="center" label="备注" prop="remark"/>
        <el-table-column align="center" class-name="small-padding fixed-width" label="操作">
          <template slot-scope="scope">
            <el-button @click="caijieOpen(scope.row)"  icon="el-icon-view" size="mini" type="text">
              拆解明细
            </el-button>
          </template>
        </el-table-column>
    </el-table>

    <div class="dialog-footer" slot="footer">
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
  <contractual-cj  ref="ContractualCj"></contractual-cj>
  </div>

</template>

<script>

    import {addAction,deleteAction, getAction, getById} from '@/api/manage'
    import ContractualCj from "../../projectBaseInfo/module/ContractualCj";
    export default {
        name: "ContractualProduct",
        dicts: ['isdo','sale_state','goods_status'],
        components: {
            ContractualCj
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                activeName: "first",
                // 弹出层标题
                title: "合同产品",
                // 是否显示弹出层
                open: false,
                // 显示搜索条件
                showSearch: true,
                // 表单参数
                form: {},
                proId: "",
                proStatus: "",
                columns: [],
                total: 0,
                // 表单校验
                rules: {
                },
                queryParams: {
                    pageNum: 1,
                    pageSize: 1000,
                    id: null,
                    code: null,
                    projectNo: null,
                    goodsName: null,
                    goodsCode: null,
                    goodsModel: null,
                    model: null,
                    brand: null,
                    isdo: null,
                    remark: null,
                    projectId: null,
                    //orderByColumn:"isdo",
                    isAsc:"desc"
                },
                url: {
                    list: '/goodsSaleChuan/goodsSaleChuan/selectListGroupByModels',
                    getById: '/projectBaseInfo/projectBaseInfo/',
                },
            };
        },
        created() {
          // this.handleQuery();
        },
        methods: {
            caijieOpen(row) {
               this.$refs.ContractualCj.caijieOpen(row);
            },
            productOpen(row){
              this.open = true;
              this.queryParams.projectId = row.id;
              this.getList();
            },
            getList(row) {
                this.loading = true;
                getAction(this.url.list, this.queryParams).then(response => {
                    this.columns = response.rows;
                    this.total = response.total;
                    this.loading = false;
                });
            },
            /** 搜索按钮操作 */
            handleQuery() {
              this.queryParams.pageNum = 1;
              this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
              this.resetForm("queryForm");
              this.handleQuery();
            },
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
          reset() {
            this.form = {
              id: null,
              goodsName: null,
            goodsCode: null,
            goodsModel: null,
            };
            this.resetForm("form");
          },
            /*handleUpdate(row) {
                this.reset();
                const id = row.id || this.ids;
                this.proId = id;
                this.proStatus = row.status;
                getById(this.url.getById, id).then(response => {
                    this.open = true;
                    this.title = "修改订单基础信息管理";
                    this.getList();
                });
            },*/
        }
    };
</script>
